#ifndef CUSTOMCOMPONENTS_H
#define CUSTOMCOMPONENTS_H

#include <QPushButton>
#include <QString>

// 带有标记的功能按钮
class MyPushButton : public QPushButton
{
    Q_OBJECT
public:
    MyPushButton(QString strTitle, int iKey, QWidget * parent = nullptr) : QPushButton(parent){
        setText(strTitle);
        m_iKey = iKey;
        connect(this, SIGNAL(clicked()), this, SLOT(slt_click()));
    }
private slots:
    void slt_click() {
        emit SendClicked(m_iKey);
    }
signals:
    void SendClicked(int);

private:
    int  m_iKey;    // 标记
};

class MyCheckBox : public QPushButton
{
    Q_OBJECT
public:
    MyCheckBox(QWidget * parent = nullptr) : QPushButton(parent){
        m_bSelected = false;
        setIcon(QIcon(":/operationIcons/resource/operationIcons/check_wait.ico"));
        connect(this, SIGNAL(clicked()), this, SLOT(slt_click()));
    }
    virtual ~MyCheckBox() {}
    void setStatus(bool bStatus)
    {
        m_bSelected = bStatus;
        changeStatus();
    }

    bool getStatus(){
        return m_bSelected;
    }

private slots:
    void slt_click() {
        m_bSelected = !m_bSelected;
        changeStatus();
        emit SendClicked(m_bSelected);
    }
signals:
    void SendClicked(bool);
private:
    // 更新状态对应的图标展示
    void changeStatus(){
        if(false == m_bSelected)
        {
            setIcon(QIcon(":/operationIcons/resource/operationIcons/check_wait.ico"));
        }
        else
        {
            setIcon(QIcon(":/operationIcons/resource/operationIcons/check_yes.ico"));
        }
    }

private:
    bool        m_bSelected;        // 被选中状态
};


#endif // CUSTOMCOMPONENTS_H
